package invoicesystem.dao.impl;

import invoicesystem.dao.BaseDataDao;
import invoicesystem.entry.BaseData;
import invoicesystem.util.DBHelper;

import java.util.ArrayList;

public class BaseDataDaoImpl implements BaseDataDao {
  private  DBHelper db=new DBHelper();

    @Override
    public boolean updateBaseData(BaseData baseData) {
        String sql =" update base_data set bank_name=?,bank_account=?,phone=?,address=? where tax_no=? ";

        int a=  db.updateinfo(sql,baseData.getBank_name(),baseData.getBank_account(),baseData.getPhone(),baseData.getAddress(),baseData.getTax_no());
        return a==0?false:true;
    }





    @Override
    public ArrayList<BaseData> selectBaseData(Integer enterprise_id) {
        String sql=" select * from base_data where enterprise_id=? ";
        BaseData baseData=new BaseData();
        baseData.setEnterprise_id(enterprise_id);
        return  db.selectinfo(sql,BaseData.class,baseData.getEnterprise_id());
    }
    @Override
    public BaseData selectById(int enterprise_id) {
        String sql="select * from bate_data where enterprise_id=?";
        ArrayList<BaseData> list=db.selectinfo(sql,BaseData.class,enterprise_id);
        return list.get(0);
    }

}
